/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package org.cjava.system.model;

import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author user
 */
@Entity
@Table(name = "business_associate", catalog = "socioscjava", schema = "")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "BusinessAssociate.findAll", query = "SELECT b FROM BusinessAssociate b")})
public class BusinessAssociate implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "id")
    private Integer id;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 15)
    @Column(name = "code")
    private String code;
    @Size(max = 15)
    @Column(name = "code_card")
    private String codeCard;
    @Basic(optional = false)
    @NotNull
    @Column(name = "start_date")
    @Temporal(TemporalType.DATE)
    private Date startDate;
    @Column(name = "code_course")
    private String codeCourse;
    // @Max(value=?)  @Min(value=?)//if you know range of your decimal fields consider using these annotations to enforce field validation
    @Basic(optional = false)
    @NotNull
    @Column(name = "price_per_associate")
    private BigDecimal pricePerAssociate;
    @Column(name = "discount")
    private Integer discount;
    @JoinColumn(name = "id_person", referencedColumnName = "id")
    @ManyToOne(optional = false)
    private Person idPerson;
    @JoinColumn(name = "id_aperture_associate", referencedColumnName = "id")
    @ManyToOne(optional = false)
    private ApertureAssociate idApertureAssociate;
    @JoinColumn(name = "id_state", referencedColumnName = "id")
    @ManyToOne(optional = false)
    private State idState;
    @JoinColumn(name = "id_system_user", referencedColumnName = "id")
    @ManyToOne(optional = true)
    private SystemUser idSystemUser;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "businessAssociateId")
    private List<BenefitBusinessAssociate> benefitBusinessAssociateList;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "idBusinessAssociate")
    private List<MeetingBusinessAssociate> meetingBusinessAssociateList;

    public BusinessAssociate() {
    }

    public BusinessAssociate(Integer id) {
        this.id = id;
    }

    public BusinessAssociate(Integer id, String code, Date startDate, BigDecimal pricePerAssociate) {
        this.id = id;
        this.code = code;
        this.startDate = startDate;
        this.pricePerAssociate = pricePerAssociate;
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public String getCodeCard() {
        return codeCard;
    }

    public void setCodeCard(String codeCard) {
        this.codeCard = codeCard;
    }

    public Date getStartDate() {
        return startDate;
    }

    public void setStartDate(Date startDate) {
        this.startDate = startDate;
    }

    public BigDecimal getPricePerAssociate() {
        return pricePerAssociate;
    }

    public String getCodeCourse() {
        return codeCourse;
    }

    public void setCodeCourse(String codeCourse) {
        this.codeCourse = codeCourse;
    }

    public void setPricePerAssociate(BigDecimal pricePerAssociate) {
        this.pricePerAssociate = pricePerAssociate;
    }

    public Integer getDiscount() {
        return discount;
    }

    public void setDiscount(Integer discount) {
        this.discount = discount;
    }

    public Person getIdPerson() {
        return idPerson;
    }
    
    public void setIdPerson(Person idPerson) {
        this.idPerson = idPerson;
    }

    public ApertureAssociate getIdApertureAssociate() {
        return idApertureAssociate;
    }

    public void setIdApertureAssociate(ApertureAssociate idApertureAssociate) {
        this.idApertureAssociate = idApertureAssociate;
    }

    public State getIdState() {
        return idState;
    }

    public void setIdState(State idState) {
        this.idState = idState;
    }

    public SystemUser getIdSystemUser() {
        return idSystemUser;
    }

    public void setIdSystemUser(SystemUser idSystemUser) {
        this.idSystemUser = idSystemUser;
    }

    @XmlTransient
    public List<BenefitBusinessAssociate> getBenefitBusinessAssociateList() {
        return benefitBusinessAssociateList;
    }

    public void setBenefitBusinessAssociateList(List<BenefitBusinessAssociate> benefitBusinessAssociateList) {
        this.benefitBusinessAssociateList = benefitBusinessAssociateList;
    }

    @XmlTransient
    public List<MeetingBusinessAssociate> getMeetingBusinessAssociateList() {
        return meetingBusinessAssociateList;
    }

    public void setMeetingBusinessAssociateList(List<MeetingBusinessAssociate> meetingBusinessAssociateList) {
        this.meetingBusinessAssociateList = meetingBusinessAssociateList;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof BusinessAssociate)) {
            return false;
        }
        BusinessAssociate other = (BusinessAssociate) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "org.cjava.system.model.BusinessAssociate[ id=" + id + " ]";
    }
    
}
